package com.jxb.first;

/**
 * 反转链表
 *
 * @author jiaobo
 * @date Created in 2024/12/8 21:35
 **/
public class ReverseLinkedList_206 {

    public ListNode reverseList(ListNode head) {
        ListNode preNode = null;
        ListNode currNode = head;
        while (currNode != null) {
            ListNode next = currNode.next;
            //将当前节点的next置为前一个节点
            currNode.next = preNode;
            preNode = currNode;
            currNode = next;
        }
        return preNode;
    }

}
